<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use yii\widgets\LinkPager;
use frontend\modules\common\models\BaseParam;

/* @var $this yii\web\View */
/* @var $searchModel frontend\modules\resource\models\BannerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Banner管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="banner-index">
    <?php Pjax::begin(['id' => 'centerView']); ?>
    <div class="searchBody">
        <?php echo $this->render('_search', ['model' => $searchModel]); ?>
        <div class="addBtn">
            <?= Html::a('+新增', 'javascript:;', ['class' => 'btn btn-success create']) ?>
        </div>
    </div>

    <?= GridView::widget([
        'options' => ['class' => 'grid-view', 'style' => 'overflow:auto', 'id' => 'grid'],
        'dataProvider' => $dataProvider,
        'columns' => [
            'id',
            'ba_name',
            'ba_url_pc' => [
                'attribute' => 'ba_url_pc',
                'contentOptions' => ['style' => 'white-space: normal;', 'width' => '10%'],
            ],
            'ba_url_mini' => [
                'attribute' => 'ba_url_mini',
                'contentOptions' => ['style' => 'white-space: normal;', 'width' => '10%'],
            ],
//            'ba_url_mini',
            'ba_sort',
//            'br_id',
            'status' => [
                'attribute' => 'status',
                'value' => function ($model) {
                    return BaseParam::CodeHelper(BaseParam::$bannerStatus, $model->status);
                }
            ],
            //'add_time',
            //'type',
            'img_url' => [
                'attribute' => 'img_url',
                'format' => [
                    'image',
                    [
                        'width' => 'auto%',
                        'height' => '50px',
                        'style' => 'display: block; margin: 0 auto;',
                    ]
                ],
                'value' => function($model){
                    return BaseParam::$imgUrl.$model->img_url;
                }
            ],
            'created_at',
            'updated_at',
            //'deleted_at',
            //功能
            [
                'class' => 'frontend\modules\common\models\ActionJsColumn',
                'template' => '{update}{delete}',
            ]
        ],
        'pager' => [
            'class' => LinkPager::className(),
            'firstPageLabel' => '首页',
            'prevPageLabel' => '《',
            'nextPageLabel' => '》',
            'lastPageLabel' => '尾页',
//            'goPageLabel' => true,
//            'totalPageLable' => '共x页',
//            'goButtonLable' => 'GO',
            'maxButtonCount' => 5,
            'hideOnSinglePage' => false,
        ]
    ]); ?>
    <?php Pjax::end(); ?>
</div>
<!--增删改 操作-->
<?php echo $this->render('../../../common/views/base/_column'); ?>
